package com.wanpinghui.supplier.object.view;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.text.Editable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextWatcher;
import android.text.style.RelativeSizeSpan;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.wanpinghui.supplier.R;
import com.wanpinghui.wphlibrary.common.RxEventType;
import com.wanpinghui.wphlibrary.common.dialog.YunBaseDialog;
import com.wanpinghui.wphlibrary.model.object.bean.DemandBean;
import com.wanpinghui.wphlibrary.model.object.bean.ObjectDetailBean;
import com.yunshl.yunshllibrary.rxbus.RxBus;
import com.yunshl.yunshllibrary.rxbus.SubscriptionBean;
import com.yunshl.yunshllibrary.view.YunShlEditText;

import org.xutils.common.util.DensityUtil;

/***
 * 功能描述:出价View
 * 作者:qiujialiu
 * 时间:2017/11/28
 ***/

public class OfferView extends LinearLayout {
    public int maxPrice = 200;
    private LinearLayout mLayoutFunction;
    private LinearLayout mLayoutFunctionMax;
    private TextView textViewBdText;
    private ImageView imageViewBdIcon;
    private TextView mButtonOne2;
    private LinearLayout mLayoutEdit;
    //    private TextView mTextViewPluses;
//    private TextView mTextViewMinues;
    private YunShlEditText mEditTextPrice;
    private ImageView mImageViewFixedPrice;
    private FrameLayout mLayoutButton2;

    private ObjectDetailBean mObjectBean;
    private OnFunctionListener functionListener;
    private int maxBid;
    private YunBaseDialog.Builder builder;
    private YunBaseDialog dialog;
    private RelativeLayout mBottomEdtOffer;

    /**
     * 获取项目当前状态
     * -1无效 1圆满完成 2独家锁定，继续跟进 3取消跟进 4派单超时未联系 5派单请尽快联系
     * 6抢单轮到自己呼叫 7竞拍成功未轮到自己呼叫 8分配中 9抢单结束 10 竞标结束  11竞拍成功自己已呼叫
     * 12竞价结束未参与 13一口价竞价中 14免费竞价中 15竞价中 16排队中 17超时未联系  18抢单轮到自己呼叫汇币不足
     * 19抢单但出局 20送单
     *
     * @return
     */
    private int type;
    private boolean isMaxPrice;//是否有人已爆灯

    public OfferView(Context context) {
        super(context);
        init(context);
    }

    public OfferView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public OfferView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    public void setFunctionListener(OnFunctionListener listener) {
        functionListener = listener;
    }

    public void setIsMaxPrice(boolean isMaxPrice) {
        this.isMaxPrice = isMaxPrice;
        if (mObjectBean != null) {
            setData(mObjectBean);
        }
    }

    private void init(final Context context) {
        builder = new YunBaseDialog.Builder(context);
        LayoutInflater.from(context).inflate(R.layout.view_object_detail_bottom, this);
        mLayoutFunction = (LinearLayout) findViewById(R.id.ll_function);
        textViewBdText = (TextView) findViewById(R.id.tv_offer);
        imageViewBdIcon = (ImageView) findViewById(R.id.iv_bd_icon);
        mLayoutEdit = (LinearLayout) findViewById(R.id.ll_edit);
        mLayoutFunctionMax = (LinearLayout) findViewById(R.id.ll_function_max);
//        mTextViewMinues = (TextView) findViewById(R.id.tv_minues);
//        mTextViewPluses = (TextView) findViewById(R.id.tv_pluses);
        mEditTextPrice = (YunShlEditText) findViewById(R.id.edt_offer);
        mImageViewFixedPrice = (ImageView) findViewById(R.id.iv_fixed_price);
        mButtonOne2 = (TextView) findViewById(R.id.button2);
        mLayoutButton2 = (FrameLayout) findViewById(R.id.fl_button2);
        mBottomEdtOffer = (RelativeLayout) findViewById(R.id.bottom_edt_offer);
        mBottomEdtOffer.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mEditTextPrice.setFocusable(true);
                mEditTextPrice.setFocusableInTouchMode(true);
                mEditTextPrice.requestFocus();
                mEditTextPrice.findFocus();
                InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(mEditTextPrice, InputMethodManager.HIDE_NOT_ALWAYS);
            }
        });
        //mButtonOne.addBindEdittext(mEditTextPrice);
        mLayoutFunction.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mEditTextPrice.getText().length() > 0) {
                    if (functionListener != null) {
                        functionListener.onOffer(mObjectBean.getDemand().getId(), Integer.parseInt(mEditTextPrice.getTextString()), Integer.parseInt(mEditTextPrice.getTextString()) == maxPrice);
                    }
                }
            }
        });
        mLayoutFunctionMax.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (functionListener != null) {
                    mEditTextPrice.setText(maxPrice + "");
                    functionListener.onOffer(mObjectBean.getDemand().getId(), maxPrice, true);
                }
            }
        });
        mLayoutButton2.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                /**
                 * 获取项目当前状态
                 * -1无效 1圆满完成 2独家锁定，继续跟进 3取消跟进 4派单超时未联系 5派单请尽快联系
                 *  6抢单轮到自己呼叫 7竞拍成功未轮到自己呼叫 8分配中 9抢单结束 10 竞标结束  11竞拍成功自己已呼叫
                 *  12竞价结束未参与 13一口价竞价中 14免费竞价中 15竞价中 16排队中 17超时未联系  18抢单轮到自己呼叫汇币不足
                 *  19抢单但出局 20送单
                 * @return
                 */
                if (functionListener != null) {
                    if (type == 14) {
                        functionListener.freeOffer(mObjectBean.getDemand().getId());
                    } else if (type == 13) {
                        int price = mObjectBean.getPrice();
                        functionListener.onOffer(mObjectBean.getDemand().getId(), price, false);
                    } else if (type == 15) {
                        functionListener.onOffer(mObjectBean.getDemand().getId(), maxPrice, true);
                    } else if (type == 6) {
                        functionListener.attach(mObjectBean.getDemand().getId(), mObjectBean.getUser().getMobile(), true);
                    } else if (type == 5 || type == 11 || type == 2 || type == 20) {
                        functionListener.attach(mObjectBean.getDemand().getId(), mObjectBean.getUser().getMobile(), false);
                    } else if (type == 18) {
                        functionListener.goMineBalance();
                    } else if (type == 1 || type == 9 || type == 10 || type == 11 || type == 12 || type == 17 || type == 19) {
                        functionListener.seeOther();
                    }
                }
            }
        });
        mEditTextPrice.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {

                if (mEditTextPrice.getText().length() > 0 && Integer.parseInt(mEditTextPrice.getTextString()) > maxPrice) {
                    mEditTextPrice.setText(maxPrice + "");
                    mEditTextPrice.setSelection(mEditTextPrice.getText().length());
                }
            }

        });
//        mTextViewPluses.setOnClickListener(new OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                if (mEditTextPrice.getText().length() > 0 && Integer.parseInt(mEditTextPrice.getTextString()) < maxPrice) {
//                    int priceI = Integer.parseInt(mEditTextPrice.getTextString()) + 1;
//                    mEditTextPrice.setText(Integer.toString(priceI));
//                }
//            }
//        });
//        mTextViewMinues.setOnClickListener(new OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                if (mEditTextPrice.getText().length() > 0 && mObjectBean != null && Integer.parseInt(mEditTextPrice.getTextString()) > mObjectBean.getDemand().getBid_start_point()) {
//                    int priceI = Integer.parseInt(mEditTextPrice.getTextString()) - 1;
//                    mEditTextPrice.setText(Integer.toString(priceI));
//                }
//            }
//        });

//        mEditTextPrice.addTextChangedListener(new TextWatcher() {
//            @Override
//            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//
//            }
//
//            @Override
//            public void onTextChanged(CharSequence s, int start, int before, int count) {
//
//            }
//
//            @Override
//            public void afterTextChanged(Editable s) {
//                if (mEditTextPrice.getText().length() > 0 && mObjectBean != null && Integer.parseInt(mEditTextPrice.getTextString()) < 0) {
//                    mEditTextPrice.setText(Integer.toString(0));
//                }
//                if (mEditTextPrice.getText().length() > 0 && Integer.parseInt(mEditTextPrice.getTextString()) > maxPrice) {
//                    mEditTextPrice.setText(Integer.toString(maxPrice));
//                }
//                if (mEditTextPrice.getText().length() > 0 && Integer.parseInt(mEditTextPrice.getTextString()) <= maxBid + 1) {
//                    mTextViewMinues.setEnabled(false);
//                } else {
//                    mTextViewMinues.setEnabled(true);
//                }
//                if (mEditTextPrice.getText().length() > 0 && Integer.parseInt(mEditTextPrice.getTextString()) == maxPrice) {
//                    mLayoutFunction.setBackgroundColor(ContextCompat.getColor(context, R.color.color_f5a623));
//                    textViewBdText.setText("我要爆灯");
//                    imageViewBdIcon.setVisibility(VISIBLE);
//                    mEditTextPrice.setTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimaryYellow));
//                    if (functionListener != null) {
//                        functionListener.showMaxPrice(false);
//                    }
//                } else {
//                    mLayoutFunction.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.selector_bg_normal_button));
//                    textViewBdText.setText("我要出价");
//                    imageViewBdIcon.setVisibility(GONE);
//                    mEditTextPrice.setTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimaryBlue));
//                    if (type == 4 && functionListener != null) {
//                        functionListener.showMaxPrice(true);
//                    }
//                }
//                mEditTextPrice.setSelection(mEditTextPrice.getText().length());
//            }
//        });
    }

    /**
     * 获取项目当前状态
     * -1无效 1圆满完成 2独家锁定，继续跟进 3取消跟进 4派单超时未联系 5派单请尽快联系
     * 6抢单轮到自己呼叫 7竞拍成功未轮到自己呼叫 8分配中 9抢单结束 10 竞标结束  11竞拍成功自己已呼叫
     * 12竞价结束未参与 13一口价竞价中 14免费竞价中 15竞价中 16排队中 17超时未联系  18抢单轮到自己呼叫汇币不足
     * 19抢单但出局 20送单
     *
     * @return
     */
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    public void setData(ObjectDetailBean objectDetailBean) {
        if (objectDetailBean == null) return;
        mObjectBean = objectDetailBean;
        DemandBean demandBean = objectDetailBean.getDemand();
        mImageViewFixedPrice.setVisibility(GONE);
        mLayoutFunction.setVisibility(VISIBLE);
        mLayoutButton2.setEnabled(true);
        if (functionListener != null) {
            functionListener.hidePhone(true);
        }
        mLayoutButton2.setBackgroundDrawable(ContextCompat.getDrawable(getContext(), R.drawable.selector_bg_normal_button));
        type = objectDetailBean.getCurrentStatus();
        System.out.println(demandBean.getStatus() + "***" + objectDetailBean.getSupplier_partic_status() + "***" + objectDetailBean.getPartic_demand_status() + "***" + objectDetailBean.getCurrentStatus());
        if (type == 1) {
            mLayoutEdit.setVisibility(GONE);
            mLayoutButton2.setVisibility(VISIBLE);
            mLayoutButton2.setEnabled(true);
            mButtonOne2.setText("去看看其他订单");
            mButtonOne2.setCompoundDrawables(null, null, null, null);
        } else if (type == 2) {
            if (demandBean.getStatus() != 9 && demandBean.getCate() != 2 && (demandBean.getCate() == 10 || demandBean.getCate() == 15 || demandBean.getCate() == 20)) {
                int money = objectDetailBean.getMy_offer() * 3 / 10;
                if (money < 1) {
                    money = 1;
                }
                builder.setTitle("竞拍成功");
                builder.setMessage("请在5分钟之内联系客户\n逾期名额作废并扣除" + money + "个(30%)汇币");
                builder.setOnClickListener(new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
                builder.setIcon(getResources().getDrawable(R.drawable.lib_toast_icon_ok));
                builder.setRightButtonText("知道了");
                if (dialog == null) {
                    dialog = builder.create();
                    dialog.show();
                }
            }
            mLayoutEdit.setVisibility(GONE);
            mLayoutButton2.setVisibility(VISIBLE);
            functionListener.hidePhone(false);
            Drawable drawable = getResources().getDrawable(R.mipmap.discover_icon_phone);
            drawable.setBounds(0, 0, DensityUtil.dip2px(17), DensityUtil.dip2px(17));
            mButtonOne2.setText(objectDetailBean.getUser().getMobile());
            mButtonOne2.setCompoundDrawables(drawable, null, null, null);
            if (functionListener != null) {
                functionListener.setBottomText("百度直推客户已采用虚拟号保护隐私");
            }
        } else if (type == 3) {
            mLayoutEdit.setVisibility(GONE);
            mLayoutButton2.setVisibility(VISIBLE);
            mLayoutButton2.setEnabled(false);
            mButtonOne2.setText("您已取消跟进");
            mButtonOne2.setCompoundDrawables(null, null, null, null);
        } else if (type == 4) {
            mLayoutEdit.setVisibility(GONE);
            mLayoutButton2.setVisibility(VISIBLE);
            mLayoutButton2.setEnabled(false);
            mButtonOne2.setText("超时未联系");
            mButtonOne2.setCompoundDrawables(null, null, null, null);
        } else if (type == 5) {
            if (demandBean.getStatus() != 9 && demandBean.getCate() != 2 && (demandBean.getCate() == 10 || demandBean.getCate() == 15 || demandBean.getCate() == 20)) {
                int money = objectDetailBean.getMy_offer() * 3 / 10;
                if (money < 1) {
                    money = 1;
                }
                builder.setTitle("竞拍成功");
                builder.setMessage("请在5分钟之内联系客户\n逾期名额作废并扣除" + money + "个(30%)汇币");
                builder.setOnClickListener(new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
                builder.setIcon(getResources().getDrawable(R.drawable.lib_toast_icon_ok));
                builder.setRightButtonText("知道了");
                if (dialog == null) {
                    dialog = builder.create();
                    dialog.show();
                }
            }
            mLayoutEdit.setVisibility(GONE);
            mLayoutButton2.setVisibility(VISIBLE);
            functionListener.hidePhone(false);
            Drawable drawable = getResources().getDrawable(R.mipmap.discover_icon_phone);
            drawable.setBounds(0, 0, DensityUtil.dip2px(17), DensityUtil.dip2px(17));
            mButtonOne2.setText(objectDetailBean.getUser().getMobile());
            mButtonOne2.setCompoundDrawables(drawable, null, null, null);
            if (functionListener != null) {
                functionListener.setBottomText("百度直推客户已采用虚拟号保护隐私");
            }
        } else if (type == 6) {
            mLayoutEdit.setVisibility(GONE);
            mLayoutButton2.setVisibility(VISIBLE);
            mLayoutButton2.setEnabled(true);
            mButtonOne2.setText("正在呼叫客户，请稍候");
            mButtonOne2.setCompoundDrawables(null, null, null, null);
            if (functionListener != null) {
                functionListener.setBottomText("联系客户时说明来自万屏汇，可提高成单率哦!");
            }
        } else if (type == 7) {
//            SpannableString spannableString = new SpannableString("竞拍成功\n约5分钟为您接通客户，注意接听0216电话");
//            spannableString.setSpan(new RelativeSizeSpan(0.5f),3,spannableString.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
//            spannableString.setSpan(new StyleSpan(Typeface.NORMAL),3,spannableString.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
//            mLayoutEdit.setVisibility(GONE);
//            mLayoutButton2.setVisibility(VISIBLE);
//            mLayoutButton2.setEnabled(false);
//            mButtonOne2.setText(spannableString);
//            mButtonOne2.setCompoundDrawables(null, null, null, null);
            mLayoutEdit.setVisibility(GONE);
            mLayoutButton2.setVisibility(VISIBLE);
            mLayoutButton2.setEnabled(false);
            mButtonOne2.setText("排到时，将通过APP通知您");
            mButtonOne2.setCompoundDrawables(null, null, null, null);
//            if (functionListener != null) {
//                functionListener.setBottomText("排到时，系统会自动帮您呼叫客户，请留意接听0216的电话");
//            }
        } else if (type == 8) {
            mLayoutEdit.setVisibility(GONE);
            mLayoutButton2.setVisibility(GONE);
        } else if (type == 9 || type == 10 || type == 12 || type == 17 || type == 19) {
            mLayoutEdit.setVisibility(GONE);
            mLayoutButton2.setVisibility(VISIBLE);
            mLayoutButton2.setEnabled(true);
            mButtonOne2.setText("去看看其他订单");
            mButtonOne2.setCompoundDrawables(null, null, null, null);
        } else if (type == 11 || type == 20) {
            if (demandBean.getStatus() != 9 && demandBean.getCate() != 2 && (demandBean.getCate() == 10 || demandBean.getCate() == 15 || demandBean.getCate() == 20)) {
                int money = objectDetailBean.getMy_offer() * 3 / 10;
                if (money < 1) {
                    money = 1;
                }
                builder.setTitle("竞拍成功");
                builder.setMessage("请在5分钟之内联系客户\n逾期名额作废并扣除" + money + "个(30%)汇币");
                builder.setOnClickListener(new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
                builder.setIcon(getResources().getDrawable(R.drawable.lib_toast_icon_ok));
                builder.setRightButtonText("知道了");
                if (dialog == null) {
                    dialog = builder.create();
                    dialog.show();
                }
            }
            functionListener.hidePhone(false);
            mLayoutEdit.setVisibility(GONE);
            mLayoutButton2.setVisibility(VISIBLE);
            Drawable drawable = getResources().getDrawable(R.mipmap.discover_icon_phone);
            drawable.setBounds(0, 0, DensityUtil.dip2px(17), DensityUtil.dip2px(17));
            mButtonOne2.setText(objectDetailBean.getUser().getMobile());
            mButtonOne2.setCompoundDrawables(drawable, null, null, null);
            if (functionListener != null) {
                functionListener.setBottomText("百度直推客户已采用虚拟号保护隐私");
            }
        } else if (type == 13) {
            mLayoutEdit.setVisibility(View.GONE);
            mLayoutButton2.setVisibility(VISIBLE);
            mButtonOne2.setCompoundDrawables(null, null, null, null);
            mImageViewFixedPrice.setVisibility(VISIBLE);
            SpannableString string = new SpannableString("我要出价 (" + mObjectBean.getPrice() + "汇币)");
            string.setSpan(new RelativeSizeSpan(0.8f), 5, 10, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            mButtonOne2.setText(string);
        } else if (type == 14) {
            mLayoutEdit.setVisibility(View.GONE);
            mLayoutButton2.setVisibility(VISIBLE);
            mButtonOne2.setText("免费抢单");
            mButtonOne2.setCompoundDrawables(null, null, null, null);
        } else if (type == 15) {
            if (objectDetailBean.getMy_offer() >= maxPrice) {
                mLayoutEdit.setVisibility(View.GONE);
                mLayoutButton2.setVisibility(VISIBLE);
                mLayoutButton2.setBackgroundDrawable(ContextCompat.getDrawable(getContext(), R.drawable.selector_bg_normal_button_yellow));
                mButtonOne2.setText("您已爆灯，请等待...");
                mLayoutButton2.setEnabled(false);
            } else {
                if (isMaxPrice) {
                    mLayoutEdit.setVisibility(GONE);
                    mLayoutButton2.setVisibility(VISIBLE);
                    mLayoutButton2.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.selector_bg_normal_button_yellow));
                    Drawable drawable = getResources().getDrawable(R.mipmap.my_icon_bd);
                    drawable.setBounds(0, 0, DensityUtil.dip2px(17), DensityUtil.dip2px(17));
                    mButtonOne2.setText("我要爆灯");
                    mButtonOne2.setCompoundDrawables(drawable, null, null, null);
                    mLayoutButton2.setEnabled(true);
                } else {
                    mLayoutEdit.setVisibility(View.VISIBLE);
                    mLayoutButton2.setVisibility(GONE);
                    if (mEditTextPrice.getText().length() == 0 && !mEditTextPrice.hasFocus()) {
                        mEditTextPrice.setText(Integer.toString(demandBean.getBid_start_point()));
                    }
                    mLayoutButton2.setEnabled(true);
                }
            }
        } else if (type == 16) {
            if (demandBean.getStatus() != 20 && demandBean.getStatus() != 30) {
                builder.setTitle("拟出局");
                builder.setMessage("若领先者放弃客户\n您将有机会获得客户信息!");
                builder.setOnClickListener(new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
                builder.setIcon(getResources().getDrawable(R.drawable.lib_toast_icon_mistake));
                builder.setRightButtonText("知道了");
                if (dialog == null) {
                    dialog = builder.create();
                    dialog.show();
                }
            }
            mLayoutEdit.setVisibility(GONE);
            mLayoutButton2.setVisibility(VISIBLE);
            mLayoutButton2.setEnabled(false);
            mButtonOne2.setText("排到时，将通过APP通知您");
            mButtonOne2.setCompoundDrawables(null, null, null, null);
//            if (functionListener != null) {
//                functionListener.setBottomText("排到时，系统会自动帮您呼叫客户，请留意接听0216的电话");
//            }
        } else if (type == 18) {
            mLayoutEdit.setVisibility(GONE);
            mLayoutButton2.setVisibility(VISIBLE);
            mButtonOne2.setText("余额不足，需缴纳" + (objectDetailBean.getMy_offer() - objectDetailBean.getLeave_bid_point()) + "汇币");
            mButtonOne2.setCompoundDrawables(null, null, null, null);

            functionListener.hidePhone(true);
        } else {
            mLayoutEdit.setVisibility(GONE);
            mLayoutButton2.setVisibility(GONE);
        }

        if (type != 15 && functionListener != null) {
            functionListener.showMaxPrice(false);
        }
    }

    public void setMaxBidCount(int maxBid) {
        this.maxBid = maxBid;
        int min = mObjectBean == null ? 0 : mObjectBean.getDemand().getBid_start_point();
        if (maxBid >= min && !mEditTextPrice.hasFocus()) {
            if (mEditTextPrice.getText().length() > 0 && Integer.parseInt(mEditTextPrice.getTextString()) < (maxBid + 1) && Integer.parseInt(mEditTextPrice.getTextString()) < maxPrice) {
                mEditTextPrice.setText(Integer.toString(maxBid + 1));
            }
        }
    }

    public interface OnFunctionListener {
        void onOffer(long id, int price, boolean isMax);

        void seeOther();

        void attach(long id, String phone, boolean firstTime);

        void goMineBalance();

        void freeOffer(long id);

        void showMaxPrice(boolean isMax);

        void hidePhone(boolean hide);

        void setBottomText(String text);
    }
}
